var a = require("../../../../@babel/runtime/helpers/toConsumableArray"), t = getApp();

Page({
    data: {
        brand_id: "",
        zoneId: "",
        inputs: "",
        datas: [],
        classifyBol: !0,
        show: !1,
        order_by: "",
        order_field: "",
        loading: !1,
        page: 1,
        allLoaded: !1
    },
    onLoad: function(a) {
        try {
            var t = wx.getStorageSync("zoneId");
            t && this.setData({
                zoneId: t
            });
        } catch (a) {}
        a.id && this.setData({
            brand_id: a.id
        }), this.gotoSearch();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.allLoaded ? console.log("没有更多数据") : (this.data.page++, this.gotoSearch(this.data.page));
    },
    onShareAppMessage: function() {
        return {
            path: "/packageB/member/category/brandgoods/brandgoods?id=" + this.data.brand_id
        };
    },
    gotoSearch: function() {
        var o = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 1, d = this, s = t.getNetAddresss("goods.goods.get-goods-brand-list");
        s += "&keywords=" + this.data.inputs, s += "&page=" + o, s += "&brand_id=" + this.data.brand_id, 
        s += "&as_id=" + this.data.zoneId, s += "&order_field=" + this.data.order_field, 
        s += "&order_by=" + this.data.order_by, t._getNetWork({
            showToastIn: !1,
            url: s,
            success: function(t) {
                var o = t.data;
                if (1 == o.result) {
                    if (d.setData({
                        loading: !1,
                        allLoaded: !1
                    }), o.data.goods.data.length <= 0) return void d.setData({
                        loading: !0,
                        allLoaded: !0
                    });
                    if (o.data.goods.current_page > o.data.goods.last_page) return void d.setData({
                        loading: !0,
                        allLoaded: !0
                    });
                    var s = d.data.datas;
                    s.push.apply(s, a(o.data.goods.data)), d.setData({
                        datas: s
                    });
                    try {
                        for (var i = 0; i < s.length; i++) 0 == Number(s[i].market_price) ? s[i].notMarket_price = 0 : s[i].notMarket_price = 1, 
                        d.setData({
                            datas: s
                        });
                    } catch (a) {
                        console.log(a);
                    }
                    try {
                        d.setData({
                            goods_template: o.data.goods.goods_template,
                            goods_style_set: o.data.goods.goods_style_set
                        }), console.log(d.data.goods_template);
                    } catch (a) {
                        console.log(e);
                    }
                    if ("02" == d.data.goods_template.names && d.setData({
                        showcccc: !0,
                        classifyBol: !1
                    }), o.data.goods.data.length < 20) return void d.setData({
                        loading: !0,
                        allLoaded: !0
                    });
                }
            },
            fail: function(a) {}
        });
    },
    inpbtn: function(a) {
        var t = a.detail.value;
        this.setData({
            inputs: t
        });
    },
    inpbtnclear: function() {
        this.setData({
            inputs: ""
        });
    },
    search: function() {
        this.data.page = 1, this.setData({
            datas: []
        }), this.gotoSearch(this.data.page, !1);
    },
    classifyBolbtn: function() {
        this.data.show ? this.setData({
            show: !1,
            classifyBol: !0
        }) : this.setData({
            show: !0,
            classifyBol: !1
        });
    },
    sortOut: function(a) {
        var t = a.detail.order_by, o = a.detail.order_field;
        0 != this.data.datas.length && (this.data.page = 1, this.setData({
            datas: [],
            order_field: o,
            order_by: t
        }), this.gotoSearch(this.data.page));
    }
});